home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / unity331.zip / OBFILT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-05-09  |  2KB  |  58 lines

  1. Program OberonError;
  2.  
  3. (* Error filter for Oberon-M compiler *)
  4. (* This is an ALPHA version of the error filter.  I wrote this as an    *)
  5. (* experiment.  Refinements and enhancements are most likely necessary! *)
  6. (* This filter should probably be written in Oberon, but I've only      *)
  7. (* played with the compiler for a couple of hours.                      *)
  8. (*                                                                      *)
  9. (* I would appreciate receiving a copy of this script that has been     *)
  10. (* rewritten in Oberon.                                                 *)
  11.  
  12. (* The command line for this program as entered with                    *)
  13. (* UINST should be: %1 %2                                               *)
  14.  
  15. Var
  16.   Source  : Text;
  17.   Line    : String;
  18.   Work    : String;
  19.   ErrLine : String;
  20.   Row,Col : String;
  21.   Index   : Integer;
  22.  
  23. Begin
  24.   Assign(Source,ParamStr(1));
  25.   Reset(Source);
  26.   While Not Eof(Source) Do
  27.   Begin
  28.     ReadLn(Source,Line);
  29.  
  30. (* This filter only catches syntax errors, other errors will slip so *)
  31. (* by be sure to make the necessary changes before relying on it!    *)
  32.  
  33.     If Pos('Syntax error',Line) = 1 Then
  34.     Begin
  35.       Index := 1;
  36.       While Not (Line[Index] In['0'..'9']) Do Inc(Index);
  37.       While Line[Index] In['0'..'9'] Do Inc(Index);
  38.       ErrLine := Copy(Line,1,Pred(Index)) + ': ';
  39.       Delete(Line,1,Index);  { start to end of line number }
  40.       Delete(Line,1,12);     { additional garbage          }
  41.       Index := Pos(' ',Line);
  42.       Row := Copy(Line,1,Pred(Index));
  43.       Delete(Line,1,Length(Row)+1);
  44.       Index := Pos(' ',Line);
  45.       Delete(Line,1,Index);
  46.       Col := Line;
  47.       ReadLn(Source,Line);
  48.  
  49.  (* The Oberon compiler doesn't include the source file name in the    *)
  50.  (* error messages, so we pass it as the second command line parameter *)
  51.  (* from UNITY.                                                        *)
  52.  
  53.       WriteLn(ParamStr(2),', ', Row,', ',Col,', ',ErrLine+Line);
  54.     End;
  55.   End;
  56.   Close(Source);
  57. End.
  58.